﻿using System;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.UI;
using Akabana.Amf.Messaging.Gateway.Configuration;
using Akabana.Amf.Messaging.Gateway.Service;
using Akabana.Amf.Util;
using log4net;

namespace Akabana.Amf.Messaging.Gateway
{
    public class GatewayPage : Page
    {
        private static ILog logger = LogManager.GetLogger(typeof(MessagingGateway));

        private MessagingServiceProcessor remotingServiceProcessor;
                
        protected override void OnInitComplete(EventArgs e)
        {
            base.OnInitComplete(e);
            lock (this)
            {
                if (remotingServiceProcessor == null)
                {
                    remotingServiceProcessor = MessagingServiceProcessor.NewInstance();
                }
            }             
        }

        protected override void OnPreLoad(EventArgs e)
        {
            if (Request.IsPostMethod())
            {
                remotingServiceProcessor.Process(Request, Response);
            }
            else
            {
            }
        }
    }
}
